<?php	
session_start();
// Need to check authentication
if (isset($_SESSION["username"][1])) {
	$pid = $_POST["pro_id"];
	$q = $_POST["qty"];
	echo $pid."---".$q."<br/>";

	//if($pid<1 or $q<1) return;


	if(isset($_SESSION['cart'])){
		$cart = $_SESSION['cart'];
		echo "session ton tai<br/>";
		if(isset($cart[$pid]))
		{
			echo "sp ton tai, qty + 1";
			$qty = $_SESSION['cart'][$pid] + 1;
		}
		else
		{
			$qty=1;
		}
		$cart[$pid] = $qty;
		$_SESSION['cart'] = $cart;
	}else{
		echo "session chua ton tai<br/>";
		$cart = array();
		$qty=1;
		$cart[$pid]=$qty;
		$_SESSION['cart'] = $cart;
	}
} else {
	echo "needLogin";
}
?>